/*
 * @Author: fhw
 * @Date: 2022-07-04 11:34:45
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-01-31 15:34:32
 * @Description:
 */
/**
 * @user: antes
 * @emial: tangzhlyd@gmail.com
 * @data: 2020/8/13 下午4:11
 */
import { forEach, keys } from 'ramda'
export interface Config {
	readonly [index: string]: { [index: string]: string | number }
}
export const optObject: Config = {
	sourceType: {
		10: '通过账号搜索',
		20: '通过名片分享',
	},
	sex: {
		男: '男',
		女: '女',
	},
}

function getOptions(data: Config): { [index: string]: Array<OptionsValue> } {
	const _obj: { [index: string]: Array<OptionsValue> } = {}
	forEach((key) => {
		const list: Array<OptionsValue> = []
		const item = data[key]
		forEach((key) => {
			const a = Number(key)
			list.push({
				value: isNaN(a) ? key : a,
				label: item[key],
			})
		}, keys(item))
		_obj[key] = list
	}, keys(data))
	return _obj
}
export const options = getOptions(optObject)
export interface OptionsValue {
	value: string | number
	label: string | number
}
